package com.bdqn.demo.service.impl;

import com.bdqn.demo.dao.UserMapper;
import com.bdqn.demo.pojo.User;
import com.bdqn.demo.service.UserService;
import com.bdqn.demo.util.Util;
import org.apache.ibatis.session.SqlSession;

public class UserServiceimpl implements UserService {

    @Override
    public int select(User user) {
        SqlSession sqlSession =Util.getSqlSession();
        int a=sqlSession.getMapper(UserMapper.class).select(user);
        if(a>0){
            return 1;
        }
        Util.clo(sqlSession);
        return 0;
    }

    //删除
    @Override
    public int delete(int id) {
        SqlSession sqlSession=Util.getSqlSession();
        int a=sqlSession.getMapper(UserMapper.class).delete(id);
        sqlSession.commit();
        Util.clo(sqlSession);
        return a;
    }

    @Override
    public int insert(User user) {
        SqlSession sqlSession=Util.getSqlSession();
        int a=sqlSession.getMapper(UserMapper.class).insert(user);
        sqlSession.commit();
        Util.clo(sqlSession);
        return a;
    }

    @Override
    public int selectCount(String username) {
        SqlSession sqlSession=Util.getSqlSession();
        int a=sqlSession.getMapper(UserMapper.class).selectCount(username);
        sqlSession.commit();
        Util.clo(sqlSession);
        return a;
    }


}
